<script setup lang="ts">
import ReCol from "@/components/ReCol";
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";
import Segmented from "@/components/ReSegmented";
import {usePublicHooks} from "@/views/system/hooks";
const { switchStyle } = usePublicHooks();

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: 0,
    state: "",
    name: "",
    attributes: '',
    logistics: '',
    channel: '',
    status: 1,
  }),
  stateList:()=>([]),
  logisticsList:()=>([]),
  goodsOptionList:()=>([]),
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);
const newFormstateList = ref(props.stateList);
console.log(666,newFormstateList)
function getRef() {
  return ruleFormRef.value;
}
defineExpose({ getRef });

</script>

<template>

  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="96px"
  >
    <el-row :gutter="30">
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="选择物流" prop="logistics">
          <el-select v-model="newFormInline.logistics" class="!w-full"
                     placeholder="选择物流" clearable>
            <el-option v-for="(item, index) in props.logisticsList" :key="index" :label="item.value" :value="item.value" />
          </el-select>
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="选择国家" prop="state">
          <el-select v-model="newFormInline.state"
            placeholder="选择国家" class="!w-full" clearable>
            <el-option class="w-full"  v-for="(item, index) in props.stateList" :key="index" :label="item.value" :value="item.value" />
          </el-select>
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="商品属性" prop="attributes">
          <el-select v-model="newFormInline.attributes"
                     placeholder="商品属性" class="!w-full" clearable>
            <el-option class="w-full"  v-for="(item, index) in props.goodsOptionList" :key="index" :label="item.value" :value="item.value" />
          </el-select>
        </el-form-item>
      </re-col>

      <re-col :value="12" :xs="24" :sm="24">
        <span></span>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="重量段低位" prop="weight_from">
          <el-input-number v-model="newFormInline.weight_from" clearable placeholder="支持两个小数" class="!w-full" :min="0.01" :step="0.01" controls-position="right" />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="重量段高位" prop="weight_to">
          <el-input-number v-model="newFormInline.weight_to" clearable placeholder="支持两个小数" class="!w-full" :min="0.01" :step="0.01" controls-position="right" />
        </el-form-item>
      </re-col>


      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="公斤价" prop="kilogram_price">
          <el-input-number v-model="newFormInline.kilogram_price" clearable placeholder="支持两个小数" class="!w-full" :min="0.01" :step="0.01" controls-position="right" />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="挂号费" prop="reg_fee">
          <el-input-number v-model="newFormInline.reg_fee" clearable placeholder="支持两个小数" class="!w-full" :min="0.01" :step="0.01" controls-position="right" />
        </el-form-item>
      </re-col>


      <re-col :value="24" :xs="24" :sm="24">
        <el-form-item label="生效日期" prop="time_start">
          <el-date-picker
            v-model="newFormInline.time_start"
            type="date" value-format="YYYY-MM-DD" format="YYYY-MM-DD"
            placeholder="请填写生效日期"
          />
        </el-form-item>
      </re-col>
      <re-col :value="12" :xs="24" :sm="24">
        <el-form-item label="状态">
          <el-switch
            v-model="newFormInline.status"
            inline-prompt
            :active-value="1"
            :inactive-value="0"
            active-text="启用"
            inactive-text="停用"
            :style="switchStyle"
          />
        </el-form-item>
      </re-col>
    </el-row>
  </el-form>

</template>
